﻿using System;
using System.ComponentModel.DataAnnotations;
using CodeFirstMVC3.Domain.Model;

namespace CodeFirstMVC3.DataAccess.Model
{
    [Table("User")]
    public class User : IUser
    {
        public int Id { get; set; }

        [ForeignKey("Member")]
        public int MemberId { get; set; }

        [ForeignKey("Job")]
        public int JobId { get; set; }

        [Required]
        public string Firstname { get; set; }

        [Required]
        public string Lastname { get; set; }

        [ForeignKey("MemberId")]
        public virtual Member Member { get; set; }

        [ForeignKey("JobId")]
        public virtual Job Job { get; set; }

        [NotMapped]
        IMember IUser.Member
        {
            get { return this.Member; }
            set { Member = value as Member; }
        }

        IJob IUser.Job
        {
            get { return this.Job; }
            set { this.Job = value as Job; }
        }
    }
}
